package cloudspace.stats.achieve;

import org.zkoss.zul.Image;
import org.zkoss.zul.Label;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;

import cloudspace.stats.StatisticType;


public class AchieveRenderer implements ListitemRenderer
{

    public void render( Listitem item, Object arg1 ) throws Exception
    {
        StatisticType achieve = (StatisticType)arg1;
        Listcell parentCell = new Listcell();
        switch ( achieve.getLevel() )
        {
            case NONE:
                ( new Label( "None" ) ).setParent( parentCell );
                break;
            case BRONZE:
                ( new Image( "/images/icons/trophies/trophy-bronze.png" ) ).setParent( parentCell );
                break;
            case SILVER:
                ( new Image( "/images/icons/trophies/trophy-silver.png" ) ).setParent( parentCell );
                break;
            case GOLD:
                ( new Image( "/images/icons/trophies/trophy-gold.png" ) ).setParent( parentCell );
                break;
            default:
                ( new Label( "Error" ) ).setParent( parentCell );
        }
        parentCell.setParent( item );
        parentCell = new Listcell();
        ( new Label( achieve.getKey() ) ).setParent( parentCell );
        parentCell.setParent( item );
        parentCell = new Listcell();
        ( new Label( achieve.getValue() + " " + achieve.getUnits() ) ).setParent( parentCell );
        parentCell.setParent( item );
    }
}
